﻿// -----------------------------------------------------------------------
// <copyright file="ControlBuilder.cs" company="Abyssalsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Gui.ThemeEngine
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;
    using System.Xml;
    using Gui.ControlBuilders;
    using Gui.WidgetBuilders;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class ControlBuilder
    {
        /// <summary>
        /// Initializes a new instance of the ControlBuilder class.
        /// </summary>
        public ControlBuilder()
        {
        }

        /// <summary>
        /// Create control
        /// </summary>
        /// <param name="control">The Xml node that contains the control properties</param>
        /// <returns>Returns a new control created from Xml properties</returns>
        public Control CreateControl(XmlNode control)
        {
            string controlType = PropertyProvider.GetValue(control, "type", string.Empty);

            switch (controlType)
            {
                case "Label":
                    CustomLabel customLabel = new CustomLabel();
                    return customLabel.GetControl(control);

                case "Button":
                    CustomButton customButton = new CustomButton();
                    return customButton.GetControl(control);

                case "Scrollbar":
                case "Slider":
                    CustomSlider customSlider = new CustomSlider();
                    return customSlider.GetControl(control);

                case "GraphicEqualizer":
                    CustomGraphicEqualizer customGraphicEq = new CustomGraphicEqualizer();
                    return customGraphicEq.GetControl(control);

                case "List":
                    CustomList customList = new CustomList();
                    return customList.GetControl(control);

                case "VideoPanel":
                    CustomVideoPanel customVideo = new CustomVideoPanel();
                    return customVideo.GetControl(control);

                case "MenuItem":
                    CustomMenu customMenu = new CustomMenu();
                    return customMenu.GetControl(control);

                case "ContextMenu":
                    CustomContextMenu customContextMenu = new CustomContextMenu();
                    return customContextMenu.GetControl(control);

                case "Panel":
                    CustomPanel customPanel = new CustomPanel();
                    return customPanel.GetControl(control);

                case "TabControl":
                    CustomTabControl customTabControl = new CustomTabControl();
                    return customTabControl.GetControl(control);

                case "ExtendedTabControl":
                    CustomExtendedTab customExtendedTab = new CustomExtendedTab();
                    return customExtendedTab.GetControl(control);

                case "Spliter":
                    CustomSplitContainer customSpliterControl = new CustomSplitContainer();
                    return customSpliterControl.GetControl(control);

                case "TextBox":
                    CustomTextBox customTextBox = new CustomTextBox();
                    return customTextBox.GetControl(control);

                case "GroupBox":
                    CustomGroupBox customGroupBox = new CustomGroupBox();
                    return customGroupBox.GetControl(control);

                case "FileTypeIcon":
                    WidgetFileTypeIcon fileTypeIcon = new WidgetFileTypeIcon();
                    return fileTypeIcon.GetControl(control);
            }

            // This is some bullshit, unknown object
            return null;
        }
    }
}
